using JetBrains.Annotations;
using Orchard.ContentManagement.Handlers;
using Orchard.Data;
using Mod.CookieDetector.Models;
using Orchard.Localization;
using Orchard.ContentManagement;

namespace Mod.CookieDetector.Handlers
{
    [UsedImplicitly]
	
    public class CookieDetectionSettingsPartHandler : ContentHandler
    {
        public CookieDetectionSettingsPartHandler(IRepository<CookieDetectionSettingsPartRecord> repository)
        {
            Filters.Add(new ActivatingFilter<CookieDetectionSettingsPart>("Site"));
            T = NullLocalizer.Instance;
            Filters.Add(StorageFilter.For(repository));
        }

        public Localizer T { get; set; }

        protected override void GetItemMetadata(GetContentItemMetadataContext context)
        {
            if (context.ContentItem.ContentType != "Site")
                return;
            base.GetItemMetadata(context);
            context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("Login")));
        }
    }
}
